﻿using Application.AppService.EIAppService;
using Application.AppService.ERAppService;
using AutoMapper;
using Domain;
using Domain.Entity;
using EFCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;

namespace UI.Controllers.RecruitmentManagement_招聘管理_.Interview_management_面试管理_
{
	public class ERResultsController : Controller
	{
		private readonly IMapper mapper;
		private readonly IERAppService eRAppService;
		private readonly IEIAppService eIAppService;
		private readonly IMemoryCache memCache;
		private readonly ILogger<ERResultsController> logger;

		public ERResultsController(IMapper mapper, IERAppService eRAppService,IEIAppService eIAppService, IMemoryCache memCache, ILogger<ERResultsController> logger)
		{
			this.mapper = mapper;
			this.eRAppService = eRAppService;
			this.eIAppService = eIAppService;
			this.memCache = memCache;
			this.logger = logger;
		}
		public IActionResult Index()
		{
			return View();
		}
		public IActionResult Index1()
		{
			return View();
		}
		[HttpPost("FYERResults")]
		public IActionResult FYERResults(int page, int pageSize)
		{
			
			ERFenYE erFenYE = eRAppService.DateERSAsync(page, pageSize, 1);
			return Json(erFenYE);
		}
		[HttpPost("AddEI")]
		public async Task<IActionResult> AddEI(EI ei)
		{
			bool rs = await eIAppService.AddEIAsync(ei);
			return Json(rs);
		}
		[HttpPost("GetEIByName")]
		public async Task<IActionResult> GetEIByName(int id)
		{
			EI ei = await eIAppService.GetEIByNameAsync(id);
			return Json(ei);
		}
		[HttpPost("UpdateERS")]
		public async Task<IActionResult> UpdateERS(ER er)
		{
			er.InterviewStatus = 2;
			bool rs = await eRAppService.UpdateERSAsync(er);
			return Json(rs);
		}
		[HttpPost("GetERByName")]
		public async Task<IActionResult> GetERByName(int id)
		{
			ER er = await eRAppService.GetERByNameAsync(id);
			return Json(er);
		}
	}
}
